package job.job_0925;
public class SimulatedLogin {//模拟登陆异常
    private String userName="小漂";//用户名
    private String userCipher="1234567";//用户密码

    public static void main(String[] args) {
        SimulatedLogin simulatedLogin=new SimulatedLogin();
        try{
            simulatedLogin.login("小漂","123456");
        }catch(CipherException e){
            e.printStackTrace();
        }
    }
    public void login(String userName,String userCipher) throws CipherException {//受查异常要抛出！！！
        if(userCipher.equals(this.userCipher)==false){
            throw new CipherException("登陆密码错误");
        }
        if(userName.equals(this.userName)){
            throw new NameException("用户名错误");
        }
    }
}
class NameException extends RuntimeException{//非受查异常
    public NameException(String message) {//有参构造
        super(message);
    }
}
class CipherException extends Exception{//受查异常
    public CipherException(String message) {
        super(message);
    }
}

